//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_addkills.sqf"
#include "x_setup.sqf"

// gameplay change:
// _points is now an array
// [points if the killer (player) is infantry unit, points if the killer is inside an APC, points if the killer is inside a tank, points if the player is inside an air vehicle]
// now, the lowest points number should be given for air vehicles and the highest for inf units
// second change: distance to target, the lower the higher, Only for infantry!!!!
private ["_points","_killer","_killed","_vec","_dist","_endpoints","_coef"];
PARAMS_3(_points,_killer,_killed);
if (isNull _killer || {!isPlayer _killer}) exitWith {};
_vec = vehicle _killer;
_endpoints = if (_vec == _killer) then {
	_dist = if (isNull _killed) then {500} else {_killed distance _killer};
	if (_dist < 0) then {_dist = 500};
	_coef = if (_dist < 20) then {3} else {if (_dist < 70) then {2} else {1}};
	_killer addScore round ((_points select 0) / 5);
	((_points select 0) * _coef)
} else {
	switch (true) do {
		case (_vec isKindOf "Wheeled_APC"): {_points select 1};
		case (_vec isKindOf "Tank"): {_points select 2};
		case (_vec isKindOf "Air"): {_points select 3};
		default {1};
	};
};
switch (side (group _killer)) do {
	case blufor: {GVAR(kill_points_blufor) = GVAR(kill_points_blufor) + _endpoints};
	case opfor: {GVAR(kill_points_opfor) = GVAR(kill_points_opfor) + _endpoints};
};